#!/bin/sh

ip link set dev usb0 up

if [ ! -d /opt/var/log ]; then
  mkdir /opt/var/log
fi

date >>/opt/var/log/usb.log
if [ ! -d /sys/class/net/usb0 ]; then
  echo no usb0 device >>/opt/var/log/usb.log 2>&1
  action=stop
elif [ "`cat /sys/class/net/usb0/carrier`" -lt 1 ]; then
  echo no carrier on usb0 >>/opt/var/log/usb.log 2>&1
  action=stop
else
  action=start
fi

echo $action >>/opt/var/log/usb.log
/home/user/bin/ipv6-share-usb $action >>/opt/var/log/usb.log 2>&1
